package com.mybatis.common;

/**
 * @author liuxiaoding
 * 冒泡排序
 * @Date 2021/8/9
 **/
public class BubbleSort {
    public static void main(String[] args) {
        int [] a = {1,6,8,7,3,5,16,4,8,36,13,44};
        sort(a);
        System.out.println("");
        for (int i:a) {

            System.out.print(i + " ");
        }
    }

    public static void sort(int [] arr){
       for(int i=0;i<arr.length;i++){
           for(int j=0;j<arr.length-1-i;j++){
               if(arr[j]>arr[j+1]){
                  int temp=arr[j];
                  arr[j]=arr[j+1];
                  arr[j+1]=temp;
               }
           }
       }
    }
}
